package com.mdp.im.core.utils;

import com.mdp.core.err.BizException;

import java.net.InetAddress;
import java.net.UnknownHostException;


public class ImTools {

    private static String hostAddress= null ;

    public static String getHostAddress(){
        if(hostAddress==null){
            try {
                InetAddress  address = InetAddress.getLocalHost();//获取的是本地的IP地址 //PC-20140317PXKX/192.168.0.121
                hostAddress = address.getHostAddress();//192.168.0.121
                return hostAddress;
            } catch (UnknownHostException e) {
                throw new BizException("获取服务器ip地址失败");
            }
        }else{
            return hostAddress;
        }
    }
}
